<?php
session_start();
require($_SERVER['DOCUMENT_ROOT'].'/resources/lib/database.php');
require($_SERVER['DOCUMENT_ROOT'].'/resources/lib/functions.php');
require($_SERVER['DOCUMENT_ROOT'].'/resources/lib/class.admin.php');
$admin = new admin();
$admin->canView($_SERVER['PHP_SELF']);
$id=$_GET['id'];
$row=$admin->getPageInformation($id);
//print_r($row);
?>
    <form class="inline" action="/admin/resources/php/requests/actions/save-blog-post.php">
    <input type="hidden" class="settings" value='{"buttonWaitingValue":"Updating post","updateNode":"#response"}' />	
	<input type="hidden" value="<?php echo($id); ?>" name="blog_page_id" id="blog_page_id" />
    <input type="hidden" value="<?php echo($row['url']); ?>" name="blog_post_url" id="blog_post_url" />
<input type="submit" class="button" value="Save changes" style="float:right;margin-right:8px;margin-top:8px;" />

<h2>Editing <?php echo($row['heading']); ?></h2>
<table width="100%" cellpadding="4" cellspacing="4">
	<tr valign="top">
    	<td width="62%"><textarea name="blog_post_content" id="blog_post_content"></textarea></td>
        <td width="38%">
<label>Post Title:</label>
<input type="text" class="comment-field req" name="blog_post_title" id="blog_post_title" value="<?php echo($row['heading']); ?>" style="width:98%;"/>
<p class="hint">Title of the blog post</p>        

<label>Tags:</label>
<input type="text" class="comment-field" name="blog_post_tags" id="blog_post_tags" value="<?php echo(implode(",",$row['tags'])); ?>"/>
<p class="hint">(comma separated tags)</p>
<label>Published:</label><br />
<select name="blog_post_active" id="blog_post_active" class="form-field" style="width:56px;"><?php echo($admin->selectYesNo($row['active'])); ?></select>
<p class="hint">Published to the world ?</p>
<label>Page Meta Keywords:</label>
<input type="text" class="comment-field" name="blog_post_meta_keywords" id="blog_post_meta_keywords" value="<?php echo($row['meta']['keywords']); ?>"/>
<p class="hint">Recommended - comma separated list</p>
<label>Page Meta Description:</label>
<input type="text" class="comment-field" name="blog_post_meta_description" id="blog_post_meta_description" value="<?php echo($row['meta']['description']); ?>"/>
<p class="hint">Recommended - around 150 characters</p>
<label>Page Title:</label>
<input type="text" class="comment-field req" name="blog_post_meta_title" id="blog_post_meta_title" value="<?php echo($row['meta']['title']); ?>"/>
<p class="hint">Required - unique page title</p>

<p class="hint">Once happy with your post please press the "Save changes" button.</p>
</td>
    </tr>
</table>
</form>
<script>

$("#st2").click();
$("#blog_post_content").wysiwyg({css: '/admin/resources/client/bundle.css',initialContent:'<?php echo($row['content']); ?>'});

</script>